package com.viking.framework.dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.viking.framework.pages.PageCut;

/**
 * 
 * @version 3.0
 * @date 2009-5-20
 */
public interface HibernateDao {

	/**
	 * 
	 * <p>
	 * Description: get all records base on mapping class
	 * </p>
	 * 
	 * @param clazz
	 * @return
	 */
	public List getAll(Class clazz);

	/**
	 * 
	 * <p>
	 * Description: get unique object according to mapping class and identify
	 * </p>
	 * 
	 * @param clazz
	 * @param id
	 * @return
	 */
	public Object getObject(Class clazz, Serializable id);

	/**
	 * <p>
	 * Description: save a serialize object
	 * </p>
	 * 
	 * @param o
	 */
	public void saveObject(Object o);

	/**
	 * <p>
	 * Description: save a serialize object
	 * </p>
	 * 
	 * @param o
	 */
	public void saveOrUpdate(Object o);

	/**
	 * 
	 * <p>
	 * Description: Update a object
	 * </p>
	 * 
	 * @param o
	 */
	public void updateObject(Object o);

	/**
	 * 
	 * <p>
	 * Description: remove/delete a object with serialize id
	 * </p>
	 * 
	 * @param clazz
	 * @param id
	 */
	public void removeObject(Class clazz, Serializable id);

	/**
	 * 
	 * @param obj
	 */
	public void removeObject(Object obj);

	/**
	 * 
	 * <p>
	 * Description: find database records by hql
	 * </p>
	 * 
	 * @param hql
	 * @param values
	 * @return
	 */
	public List findByHql(String hql, Object values[]);

	/**
	 * 
	 * <p>
	 * Description: find records by page
	 * </p>
	 * 
	 * @param hql
	 * @param values
	 * @param start
	 * @param limit
	 * @return
	 */
	public PageCut pageQueryByHql(String hql, Object values[], int start,
			int limit);

	/**
	 * 
	 * <p>
	 * Description: find records by page
	 * </p>
	 * 
	 * @param hql
	 * @param values
	 * @param start
	 * @param limit
	 * @return
	 */
	public PageCut pageQueryBySql(String sql, Object values[], int start,
			int limit);

	/**
	 * 
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param hql
	 * @param values
	 */
	public int bulkUpdate(String hql, Object values[]);

	/**
	 * 
	 * <p>
	 * Description: execute SQL update
	 * </p>
	 * 
	 * @param sql
	 * @param values
	 * @return
	 */
	public int executeSqlUpdate(String sql, Object values[]);

	/**
	 * 
	 * <p>
	 * Description: execute SQL Query
	 * </p>
	 * 
	 * @param sql
	 * @param values
	 * @return
	 */
	public List executeSqlQuery(String sql, Object values[]);

	/**
	 * 
	 * <p>
	 * Description: get hibernate session
	 * </p>
	 * 
	 * @return
	 */
	public Session getHibernateSession();

	/**
	 * 
	 * <p>
	 * Description: get hibernate template
	 * </p>
	 * 
	 * @return
	 */
	public HibernateTemplate getHibernateTemplate();
}
